<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>Bootstrap 101 Template</title>

    <!-- Bootstrap -->
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <script src="js/jquery-1.11.0.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <script src="js/getParameter.js"></script>
    <style type="text/css">
        td, th {
            text-align: center;
        }
        table{
            width:100px;
            table-layout:fixed;/* 只有定义了表格的布局算法为fixed，下面td的定义才能起作用。 */
        }
        td{
            width:100%;
            word-break:keep-all;/* 不换行 */
            white-space:nowrap;/* 不换行 */
            overflow:hidden;/* 内容超出宽度时隐藏超出部分的内容 */
            text-overflow:ellipsis;/* 当对象内文本溢出时显示省略标记(...) ；需与overflow:hidden;一起使用*/
        }
        .main_div{
            margin: auto;
            width: 1000px;

        }
        .nav_div{
            float: left;
            width: 250px;
        }
        .delete{
            float: right;
            margin-bottom: 10px;
        }
        /*
        分页
         */

        .pageNum ul li {
            float: left;
            /*border: 1px solid #eee;*/
            margin-right: 10px;
            text-align: center;
            /*line-height: 40px;*/
        }
        /*.pageNum ul li a {*/
        /*width: 100%;*/
        /*height: 100%;*/
        /*color: #000;*/
        /*font-size: 14px;*/
        /*}*/
        footer{
            bottom: 0;
            left: 0;
        }
    </style>
</head>
<body>
<nav class="navbar navbar-default">
    <div class="container-fluid">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="#" style="font-weight: bolder">我的主页</a>
        </div>

        <!-- Collect the nav links, forms, and other content for toggling -->
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <ul class="nav navbar-nav" style="font-weight: bolder">
                <li class="active"><a href="#">我所发布的<span class="sr-only">(current)</span></a></li>
                <li><a href="#">我的买卖</a></li>
                <li><a href="writepage.html">我想说说</a></li>
                <li><a href="index.html">回到主页</a></li>
            </ul>
            <form class="navbar-form navbar-left">
                <div class="form-group">
                    <input type="text" class="form-control" placeholder="Search" id="sinput">
                </div>
                <a href="javascript:" class="btn btn-default btn-lg" id="sbtn" role="button" style="height: 35px;font-size: 18px;line-height: 15px">搜索</a>
            </form>
            <ul class="nav navbar-nav navbar-right" style="font-weight: bolder">
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">我的资料<span class="caret"></span></a>
                    <ul class="dropdown-menu">
                        <li><a href="/modifiy.html">修改个人资料</a></li>
                        <li><a href="#">使用说明</a></li>
                        <li><a href="#">买卖帮助</a></li>
                    </ul>
                </li>
            </ul>
        </div><!-- /.navbar-collapse -->
    </div><!-- /.container-fluid -->
</nav>
<div class="nav_div" id="nav_div">
    <ul class="nav nav-pills nav-stacked" style="font-weight: bolder;font-size: 18px">
        <li role="presentation" id="bar-1"><a href="searchpage.html?cid=1">学习圈</a></li>
        <li role="presentation" id="bar-7"><a href="searchpage.html?cid=2">吐槽圈</a></li>
        <li role="presentation" id="bar-3"><a href="searchpage.html?cid=3">男女那些事</a></li>
        <li role="presentation" id="bar-4"><a href="searchpage.html?cid=4">废品重用</a></li>
        <li role="presentation" id="bar-5"><a href="searchpage.html?cid=5">学术资源分享</a></li>
        <li role="presentation" id="bar-6"><a href="searchpage.html?cid=6">下课后</a></li>
        <li role="presentation" id="bar-2">
            <a href="#docCollapse" class="nav-header collapsed" data-toggle="collapse" id="collapseParent" onclick="chevron_toggle()">开发人名单<span class="pull-right glyphicon glyphicon-chevron-down"></span></a>
            <ul id="docCollapse" class="nav nav-list collapse">
                <li><a href="#">感谢支持</a></li>
                <li><a href="#">开发不易</a></li>
                <li><a href="#">如弟</a></li>
                <li><a href="#">GC</a></li>
                <li><a href="#">黑豚</a></li>

            </ul>
        </li>
    </ul>
</div>
<div class="container main_div">
    <a href="#" class="btn btn-primary btn-lg active delete" role="button" id="delete">删除选中</a>
    <form  id="form">
        <div id="table">
            <!--<table  class="table table-striped table-hover">-->
            <!--<tr class="info">-->
            <!--<th><input type="checkbox" id="firstCb"></th>-->
            <!--<th>发布日期</th>-->
            <!--<th>发布区</th>-->
            <!--<th>标题</th>-->
            <!--<th>内容</th>-->
            <!--<th>操作</th>-->
            <!--</tr>-->
            <!--<tr>-->
            <!--<td><input type="checkbox" name="uid" ></td>-->
            <!--<td>1</td>-->
            <!--<td>张三</td>-->
            <!--<td>男</td>-->
            <!--<td>男</td>-->
            <!--<td><a class="btn btn-default btn-sm" href="">删除</a></td>-->
            <!--</tr>-->
            <!--<tr>-->
            <!--<td><input type="checkbox" name="uid" ></td>-->
            <!--<td>2</td>-->
            <!--<td>张三</td>-->
            <!--<td>男</td>-->
            <!--<td>男</td>-->
            <!--<td><a class="btn btn-default btn-sm" href="">删除</a></td>-->
            <!--</tr>-->
            <!--<tr>-->
            <!--<td><input type="checkbox" name="uid" ></td>-->
            <!--<td>3</td>-->
            <!--<td>张三</td>-->
            <!--<td>男</td>-->
            <!--<td>男</td>-->
            <!--<td><a class="btn btn-default btn-sm" href="">删除</a></td>-->
            <!--</tr>-->
            </table>
        </div>
    </form>
    <div style="background-color: grey;width: 8px;height:30px;float: left" >
    </div>
    <div style="color: red;font-weight: bolder;font-size: 25px">
        <i></i>共
        <span id="totalPage" style="color: orange"></span>页<span id="totalCount" style="color: orange;"></span>条
    </div>
    <br>
    <div class="pageNum">
        <nav aria-label="Page navigation">
            <ul class="pagination pagination-lg" id="pageNum">
                <li>
                    <a href="#" aria-label="Previous">
                        <span aria-hidden="true">&laquo;</span>
                    </a>
                </li>
                <li><a href="#">1</a></li>
                <li><a href="#">2</a></li>
                <li><a href="#">3</a></li>
                <li><a href="#">4</a></li>
                <li><a href="#">5</a></li>
                <li>
                    <a href="#" aria-label="Next">
                        <span aria-hidden="true">&raquo;</span>
                    </a>
                </li>
            </ul>
        </nav>
    </div>
</div>
<footer class="container-fluid xueba1" style="margin-top: 20px;">
    <div class="row" style="background-color:#e6e6e6;color:#777777;text-align: center">
        <img src="img/logo.png" style="float: left" width="150px" height="60px">
        <div  class="col-md-8">
            <p style="float: left">学声网为如弟，GC，大豚哥开发，内容尚未完善</p><br><br>
            <p style="float: left">版权由开发者所有，感谢支持</p>
        </div>
        <div style="margin-left:700px;margin-top: -55px" class="col-md-4">
            <a rel="nofollow" href="http://www.beian.miit.gov.cn" ><span>备案号：</span>苏ICP备19067655号</a><br>
            <a href="#" style="color: #777777">联系方式</a>
        </div>
    </div>
</footer>
<script>
    function chevron_toggle(){
        $("#collapseParent").find("span").toggleClass("glyphicon-chevron-up");
        $("#collapseParent").find("span").toggleClass("glyphicon-chevron-down");
    }
    $(function () {
        load();
    })
    function load(currentPage) {
        $.get("topic/pageQueryForUser",{currentPage:currentPage},function (pb) {
            $("#totalPage").html(pb.totalPage);
            $("#totalCount").html(pb.totalCount);
            var lis="";
            var firstpage='<li><a href="javascript:load()">首页</a></li>';
            var beforePage=pb.currentPage-1;
            if (beforePage<=0){
                beforePage=1;
            }
            var previous='<li> <a href="javascript:load('+beforePage+')" aria-label="Previous"> <span aria-hidden="true">&laquo;</span></a></li>';
            lis+=firstpage;
            lis+=previous;
            var begin;
            var end;
            if (pb.totalPage < 10) {
                begin = 1;
                end = pb.totalPage;
            } else {
                begin = pb.currentPage - 5;
                end = pb.currentPage + 4;
                if (begin < 1) {
                    begin = 1;
                    end = begin + 9;
                }
                if (end > pb.totalPage) {
                    end = pb.totalPage;
                    begin = end - 9;
                }
            }


            for (var i = begin; i <=end; i++) {
                var li;
                if (pb.currentPage==i) {
                    li = '<li class="active"><a href="javascript:load(' + i + ')">' + i + '</a></li>';
                }
                else {
                    li = '<li><a href="javascript:load(' + i + ')">' + i + '</a></li>';
                }
                lis+=li;
            }
            // for (var i=1;i<=pb.totalPage;i++){
            //     var li;
            //     if (pb.currentPage==i) {
            //         li = '<li class="active"><a href="javascript:load(' + i + ')">' + i + '</a></li>';
            //     }
            //     else {
            //         li = '<li><a href="javascript:load(' + i + ')">' + i + '</a></li>';
            //     }
            //     lis+=li;
            // }
            var next=pb.currentPage+1;
            if (next>=pb.totalPage){
                next=pb.totalPage;
            }
            var nextpage='<li> <a href="javascript:load('+next+')" aria-label="Next"> <span aria-hidden="true">&raquo;</span> </a> </li>';

            var lastPage='<li><a href="javascript:load('+pb.totalPage+')">尾页</a></li>';
            lis+=nextpage;
            lis+=lastPage;
            $("#pageNum").html(lis);

            var topic_list="";
            var firstTable= '<table  class="table table-striped table-hover"> <tr class="info"> <th><input type="checkbox" id="firstCb"></th><th>发布日期</th> <th>发布区</th> <th>标题</th> <th>内容</th><th>点赞数</th> <th>操作</th></tr>';
            topic_list+=firstTable;
            for (var i=0;i<pb.list.length;i++) {
                var topic=pb.list[i];
                var tli= '<tr><td><input type="checkbox" name="uid" value="'+topic.tid+'"></td> <td>'+topic.date+'</td> <td>'+topic.cname+'</td> <td><a href="contextpage.html?tid='+topic.tid+'">'+topic.title+'</a></td> <td>'+topic.context+'</td></td><td>'+topic.thumbup+'</td> <td><a class="btn btn-default btn-sm" href="javascript:deleteC('+topic.tid+')">删除</a></tr>';
                topic_list+=tli;
                var tid=topic.tid;
            }
            $("#table").html(topic_list);
            window.scrollTo(0,0);
            $("#firstCb").click(function () {
                var uid = document.getElementsByName("uid");
                for (var i=0;i<uid.length;i++){
                    uid[i].checked=this.checked;
                }
            })
        },"json");
    }

</script>
<script>
    function deleteC(tid) {
        if (confirm("确定删除当前记录")) {
            $.post("user/deleteMsg", {tid: tid}, function () {
            }, "json");
            location.href="personalpage.html";
        }
    }
    $("#delete").click(function () {
        if(confirm("确定删除选中的吗")) {
            $.post("user/deleteAllMsg", $("#form").serialize(), function () {
            }, "json");
            location.href = "personalpage.html";
        }
    })
</script>
</body>
</html>